// import Taro from '@tarojs/taro';
import { indexGoods } from '../../../utils/api';

export default {
  namespace: 'goods',
  state: {
    goods: []
  },

  effects: {
    * getGoods({ payload }, { call, put }) {
      const result = yield call(indexGoods, {
        ...payload
      })
      yield put({
        type: 'updateStateWithGoods',
        payload: {
          goods: result
        }
      })
    }
  },

  reducers: {
    updateStateWithGoods(state, { payload: goods }) {
      return { ...state, ...goods }
    }
  }

}
